<%
layout("tabbar.html"){
%>
<div class="page__bd">
    <div class="weui-cells__title">资金记录</div>
    <div class="weui-cells" id="recordList">
        <!-- <div class="weui-cell">
            <div class="weui-cell__bd">
                <p>消息</p>
            </div>
            <div class="weui-cell__ft">
                <p>金额</p>
                <p>riqi</p>
            </div>
        </div> -->
    </div>
    <a id="loadMoreButton" href="javascript:" style="margin-top: 20px;" class="weui-btn weui-btn_default">加载更多</a>
</div>
<script src="${ctxPath}/js/net.js"></script>
<script>
    var page = 1;

    function fetchData() {
        net()
            .url('${ctxPath}/api/user/moneyRecords?page=' + page)
            .success(function (response) {
                if (response.code == 0) {
                    if (response.data.length == 0) {
                        alert('没有更多数据');
                        $('#loadMoreButton').hide();
                    }
                    page ++;
                    response.data.forEach(function (t) {
                        $('#recordList').append('<div class="weui-cell"><div class="weui-cell__bd"><p>' + t.message + '</p></div><div class="weui-cell__ft">' + (t.money / 100) + '元</div></div>');
                    })
                } else {
                    alert(response.message);
                }
            })
            .error(function () {
                alert('请求错误');
            })
            .get();
    }

    fetchData();

    $('#loadMoreButton').click(function () {
        fetchData();
    });

</script>
<% } %>